// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <memory>
#include <string>
#include <type_traits>
#include <vector>

#include <nebula/types/type.h>
#include <nebula/bits/bit_util.h>

namespace nebula {
    //
    // Per-type id type lookup
    //

    template<Type::type id>
    struct TypeIdTraits {
    };

#define TYPE_ID_TRAIT(_id, _typeclass) \
template <>                          \
struct TypeIdTraits<Type::_id> {     \
using Type = _typeclass;           \
};

    TYPE_ID_TRAIT(NA, NullType)

    TYPE_ID_TRAIT(BOOL, BooleanType)

    TYPE_ID_TRAIT(INT8, Int8Type)

    TYPE_ID_TRAIT(INT16, Int16Type)

    TYPE_ID_TRAIT(INT32, Int32Type)

    TYPE_ID_TRAIT(INT64, Int64Type)

    TYPE_ID_TRAIT(UINT8, UInt8Type)

    TYPE_ID_TRAIT(UINT16, UInt16Type)

    TYPE_ID_TRAIT(UINT32, UInt32Type)

    TYPE_ID_TRAIT(UINT64, UInt64Type)

    TYPE_ID_TRAIT(FP16, Fp16Type)

    TYPE_ID_TRAIT(FP32, Fp32Type)

    TYPE_ID_TRAIT(FP64, Fp64Type)

    TYPE_ID_TRAIT(STRING, StringType)

    TYPE_ID_TRAIT(BINARY, BinaryType)

    TYPE_ID_TRAIT(LARGE_STRING, LargeStringType)

    TYPE_ID_TRAIT(LARGE_BINARY, LargeBinaryType)

    TYPE_ID_TRAIT(FIXED_SIZE_BINARY, FixedSizeBinaryType)

    TYPE_ID_TRAIT(DATE32, Date32Type)

    TYPE_ID_TRAIT(DATE64, Date64Type)

    TYPE_ID_TRAIT(TIME32, Time32Type)

    TYPE_ID_TRAIT(TIME64, Time64Type)

    TYPE_ID_TRAIT(TIMESTAMP, TimestampType)

    TYPE_ID_TRAIT(INTERVAL_DAY_TIME, DayTimeIntervalType)

    TYPE_ID_TRAIT(INTERVAL_MONTH_DAY_NANO, MonthDayNanoIntervalType)

    TYPE_ID_TRAIT(INTERVAL_MONTHS, MonthIntervalType)

    TYPE_ID_TRAIT(DURATION, DurationType)

    TYPE_ID_TRAIT(DECIMAL128, Decimal128Type)

    TYPE_ID_TRAIT(DECIMAL256, Decimal256Type)

    TYPE_ID_TRAIT(STRUCT, StructType)

    TYPE_ID_TRAIT(LIST, ListType)

    TYPE_ID_TRAIT(LARGE_LIST, LargeListType)

    TYPE_ID_TRAIT(FIXED_SIZE_LIST, FixedSizeListType)

    TYPE_ID_TRAIT(MAP, MapType)

    TYPE_ID_TRAIT(DENSE_UNION, DenseUnionType)

    TYPE_ID_TRAIT(SPARSE_UNION, SparseUnionType)

    TYPE_ID_TRAIT(DICTIONARY, DictionaryType)

    TYPE_ID_TRAIT(EXTENSION, ExtensionType)

#undef TYPE_ID_TRAIT
} // namespace nebula
